package cn.doitedu.driver;

import cn.doitedu.common.Task;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Driver {

    public static void main(String[] args) throws IOException {

        // 生成两个task，发给两个executor去执行
        Task task1 = new Task("task-1");
        Task task2 = new Task("task-2");


        Socket socket1 = new Socket("doit02", 16200);
        Socket socket2 = new Socket("doit03", 16200);


        // 发送对象
        OutputStream out1 = socket1.getOutputStream();
        ObjectOutputStream objout1 = new ObjectOutputStream(out1);
        objout1.writeObject(task1);

        objout1.close();
        out1.close();
        socket1.close();


        OutputStream out2 = socket2.getOutputStream();
        ObjectOutputStream objout2 = new ObjectOutputStream(out2);
        objout2.writeObject(task2);

        objout2.close();
        out2.close();
        socket2.close();
    }
}
